package com.reform.controller.expert;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.reform.pojo.expert.ViewExpertLabel;
import com.reform.res.Result;
import com.reform.res.ResultCode;
import com.reform.service.IExpertService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author mortale
 * @since 2021-06-26
 */
@Api(tags = "ExpertController")
@RestController
@RequestMapping("/expert")
public class ExpertController {

    @Autowired
    IExpertService expertService;

    @ApiOperation(value = "获取全部专家信息", notes = "获取全部专家信息")
    @GetMapping("/getExperts")
    public Result getExperts() throws SQLException {
        return expertService.getExperts();
    }

    @ApiOperation(value = "通过batchId获取专家信息", notes = "通过batch_id获取专家信息")
    @PostMapping("/getExpertByBatchId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "batchId", value = "批次id", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getExpertByBatchId(String batchId) throws SQLException {
        return expertService.getExpertByBatchId(batchId);
    }

    @ApiOperation(value = "创建专家信息", notes = "创建专家信息")
    @PostMapping("/creatExpert")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "experts", value = "专家信息JSON字符串数组", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result creatExpert(String experts) throws SQLException {
        return expertService.creatExpert(experts);
    }

    @ApiOperation(value = "删除专家信息", notes = "删除专家信息")
    @PostMapping("/deleteExpert")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "experts", value = "专家信息JSON字符串数组", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result deleteExpert(String experts) throws SQLException {
        return expertService.deleteExpert(experts);
    }

    @ApiOperation(value = "通过教师工号获取专家batchId信息", notes = "通过教师工号获取专家batchId信息")
    @GetMapping("/getBatchInfo")
    public Result getBatchInfo(HttpServletRequest request) throws SQLException {
        return expertService.getBatchInfo(request);
    }

    @ApiOperation(value = "通过教师工号获取专家phaseId信息", notes = "通过教师工号获取专家phaseId信息")
    @GetMapping("/getPhaseInfo")
    public Result getPhaseInfo(HttpServletRequest request) throws SQLException {
        return expertService.getPhaseInfo(request);
    }

}
